/**
 * Copyright(C) 2019 FUYUN DATA SERVICES CO., LTD. - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * Proprietary and confidential
 * 该源代码版权归属福韵数据服务有限公司所有
 * 未经授权，任何人不得复制、泄露、转载、使用，否则将视为侵权
 */

import request from "../../../../utils/request";
import { stringify } from "querystring";
import { SERVER_URL } from "../../../../config/base";

// 查询商品列表数据
export async function getGoodsList(payload: any) {
  return request(`${SERVER_URL}/goods?${stringify(payload)}`, {
    method: "get",
    data: {}
  });
}

// 查询商品数据
export async function getGoodsById(id: any) {
  return request(`${SERVER_URL}/goods/` + id, {
    method: "get",
    data: {}
  });
}

// 保存商品数据
export async function saveGoods(payload: any) {
  return request(`${SERVER_URL}/goods`, {
    method: "post",
    data: payload
  });
}

// 修改商品数据
export async function editGoods(payload: any) {
  return request(`${SERVER_URL}/goods/` + payload.id, {
    method: "put",
    data: payload
  });
}

// 修改商品数据
export async function uploadGoods(payload: any) {
  return request(`${SERVER_URL}/pseudo/upload`, {
    method: "post",
    data: payload
  });
}

export async function deleteGoods(id: string) {
  return request(`${SERVER_URL}/goods/` + id, {
    method: "delete",
    data: {}
  });
}

export async function findByProId(id: string) {
  return request(`${SERVER_URL}/goods/findProId?proId=` + id, {
    method: "get",
    data: {}
  });
}
